package test0ne.多线程;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class TestAtomicBoolean {

    private static volatile AtomicBoolean boo = new AtomicBoolean(false);

    private static AtomicInteger count = new AtomicInteger(0);

    static class Worker implements Runnable{

        @Override
        public void run() {
            if(!boo.get()) {
                System.out.println(boo.get());
                SleepUtils.second(2000);
                count.getAndAdd(1);
                System.out.println(count);
                if(count.get() == 100) {
                    boo.set(true);
                }

            }
        }
    }

    public static void main(String[] args) {
        Worker worker = new Worker();
        worker.run();
    }
}
